package com.phospherus.common.controller.handler;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author songjinlong
 * @version 1.0
 * @since 2017/04/18
 */
public class Data<T> {
    private Collection<T> datas;

    public Data() {
    }

    public Data(Collection<T> datas) {
        this.datas = datas;
    }

    public Collection<T> getDatas() {
        return datas;
    }

    public void setDatas(Collection<T> datas) {
        this.datas = datas;
    }

    public Data add(T data) {
        if (datas == null) {
            datas = new ArrayList<>();
        }
        datas.add(data);
        return this;
    }

    public Data add(Collection<T> datas) {
        if (this.datas == null) {
            this.datas = datas;
        }
        this.datas.addAll(datas);
        return this;
    }
}